<template>
	<view class="content">
		<view class="Box">
			<view class="BoxView">
				<view class="BoxOne">
					<u--image :showLoading="true" :src="info.avatar" width="160rpx" height="160rpx" radius="0"
						shape="circle"></u--image>
					<view class="BoxContent">
						<view class="BoxTop marginBottom">
							<text class="title">{{info.name || ''}}</text>
							<text style="color:#888888;margin-left:15rpx;">{{info.speciality || ''}}</text>
						</view>
						<view class="BoxTop marginBottom">
							<u--image :showLoading="true" src="../../static/Home/shoucang.png" width="24rpx" height="24rpx"
								radius="0"></u--image>
							<text class="fen">{{info.avg_comment_score || ''}}</text>
						</view>
						<view class="BoxTop">
							<text class="Newtitle">{{info.description || ''}}</text>
						</view>
					</view>
				</view>
				<u--image :showLoading="true" src="../../static/Home/heiaixin.png" width="32rpx" height="32rpx"
					radius="0"></u--image>
			</view>
		</view>

		<view class="headers_title">
			<view class="view"></view>
			<text>关于老师</text>
		</view>

		<view class="scrollBody">
			<text>{{info.description || ''}}</text>
		</view>

		<view class="headers_title">
			<view class="view"></view>
			<text>工作时间</text>
		</view>

		<view class="working_hours">
			<view class="view">
				<u--image :showLoading="true" src="../../static/Home/rqi.png" width="34rpx" height="34rpx"
					radius="0"></u--image>
				<text>周一至周六</text>
			</view>
			<view class="view">
				<u--image :showLoading="true" src="../../static/Home/shijian.png" width="34rpx" height="34rpx"
					radius="0"></u--image>
				<text>30分钟/节</text>
			</view>
		</view>

		<view class="headers_Flex">
			<view class="headers_title" style="margin-top:0rpx;">
				<view class="view"></view>
				<text>预约时间</text>
			</view>
			<u-number-box v-model="req.nums" @change="valChange"></u-number-box>
		</view>

		<view class="headers">
			<kc :value="req.nums"></kc>
		</view>

		<view class="buttonFlex">
			<button class="Single_appointment" @click="LinkUrl(1)">1v1固定预约</button>
			<button class="Single_appointment" style="background-color:#efefef;color:#333;"
				@click="LinkUrl(2)">1v2固定预约</button>
		</view>
	</view>
</template>

<script>
	import {
		teacherLists,
		collectTeacher,
		teacher_category,
		teacherCountry,
		teacher_info,
	} from '../../api/Teacher.js';
	import kc from '../../components/kc/kc.vue';
	export default {
		components: {
			kc
		},
		data() {
			return {
				scrollTop: 0,
				courses: [{
					name: '全部'
				}, {
					name: '英语'
				}, {
					name: '法语'
				}, {
					name: '俄语'
				}],
				info:{},
				req: {
					teacher_id: 0,
					shop_id: 0,
					date: '',
					nums: 1, //周数
					content: [], //week：1-7对应星期一到星期日
					type: '', //1：1v1固定课程，2:1v2固定课程
				}
			}
		},
		onLoad(option) {
			this.req = {
				...this.req,
				...{
					teacher_id: option.id,
					shop_id: uni.getStorageSync('shop_id') || 1
				}
			};
			this.teacher_info(option.id, this.req.date);
		},
		mounted() {
			uni.$on('kcCheck', (e) => {
				let arrs = new Array();
				for (var i = 0; i < e.length; i++) {
					for (var j = 0; j < e[i].children.length; j++) {
						if (e[i].children[j].is_setting == 1) {
							arrs.push({
								"week": j+1,
								"start_time": e[i].time
							});
						}
					}
				}
				this.req.content = [...arrs];
			});
		},
		methods: {
			transformText(index) {
				let TextTime = [
					'一',
					'二',
					'三',
					'四',
					'五',
					'六',
					'日',
				];
				return TextTime[index];
			},
			/**
			@method 老师所属国家
			**/
			async teacher_info(teacher_id, date) {
				try {
					const res = await teacher_info({
						teacher_id: teacher_id,
						date: date
					});
					this.info = {
						...res.data
					};
				} catch (err) {
					//TODO handle the exception
					console.log(err);
				}
			},
			valChange(e) {
				console.log(e);
			},
			LinkUrl(e) {
				let Strs = new Array();
				if (this.req.content.length > 0) {
					Strs = [...this.req.content];
					this.req = {
						...this.req,
						...{
							type: e,
							content: JSON.stringify(Strs)
						}
					};
					uni.navigateTo({
						url: `/pages/Order/pay?payinfo=${JSON.stringify(this.req)}`
					});
				} else {
					uni.showToast({
						title: '请选择预约时间！',
						icon: 'none',
						duration: 2000
					});
					return false;
				}
			}
		}
	}
</script>

<style>
	page {
		background-color: #f7f7f7;
	}
</style>
<style scoped lang="scss">
	.content {
		width: auto;
		height: 30vh;
		padding: 30rpx;

		background: linear-gradient(182deg, #EDF6FD 0%, #C8EEFD 0%, #f7f7f7 72%, #f7f7f7 100%);
		position: relative;

		.headers_Flex {
			display: flex;
			align-items: center;
			justify-content: space-between;
			margin-top: 60rpx;
		}

		.buttonFlex {
			display: flex;
			justify-content: space-between;
			align-items: center;
		}

		.Single_appointment {
			width: 308rpx;
			height: 70rpx;
			margin: 0px auto;
			border-radius: 50rpx;
			background-color: #1f86ff;
			color: #fff;
			display: flex;
			justify-content: center;
			align-items: center;
			font-size: 28rpx;
			letter-spacing: 2rpx;
			margin-top: 60rpx;
			margin-bottom: 60rpx;
		}

		.statusType {
			display: flex;
			align-items: center;
			margin-top: 30rpx;

			.leftview {
				display: flex;
				align-items: center;
				margin-right: 30rpx;

				view {
					width: 62rpx;
					height: 14rpx;
					background-color: #1f86ff;
					border-radius: 50rpx;
				}

				text {
					font-family: PingFangSC, PingFang SC;
					font-weight: 400;
					font-size: 24rpx;
					color: #333333;
					margin-left: 10rpx;
				}
			}

			.rightview {
				display: flex;
				align-items: center;

				view {
					width: 62rpx;
					height: 14rpx;
					background-color: #eaeaea;
					border-radius: 50rpx;
				}

				text {
					font-family: PingFangSC, PingFang SC;
					font-weight: 400;
					font-size: 24rpx;
					color: #333333;
					margin-left: 10rpx;
				}
			}
		}

		.button_flex {
			display: flex;
			justify-content: space-between;
			align-items: center;
			margin-top: 40rpx;

			button {
				width: 140rpx;
				height: 50rpx;
				font-family: PingFangSC, PingFang SC;
				font-weight: 500;
				font-size: 26rpx;
				border-radius: 46rpx;
				margin: 0px;
				display: flex;
				justify-content: center;
				align-items: center;
				color: #fff;
			}
		}

		.Box {
			padding-bottom: 30rpx;

			.BoxView {
				width: auto;
				margin: 0px auto;
				// background-color: #fff;
				border-radius: 20rpx;

				display: flex;
				justify-content: space-between;
				align-items: center;
			}

			.BoxOne {
				display: flex;
				justify-content: space-between;
				align-items: center;

				.marginBottom {
					margin-bottom: 10rpx;

					.fen {
						font-family: PingFangSC, PingFang SC;
						font-weight: 600;
						font-size: 28rpx;
						color: #FE7000;
						margin-left: 5rpx;
					}
				}

				.BoxTop {
					margin-left: 20rpx;
					display: flex;
					align-items: center;

					text {
						display: block;
						font-size: 24rpx;
					}

					.title {
						font-family: PingFangSC, PingFang SC;
						font-weight: 600;
						font-size: 32rpx;
						color: #333333;
						font-style: normal;
					}

					.Newtitle {
						font-family: PingFangSC, PingFang SC;
						font-weight: 500;
						font-size: 24rpx;
						color: #666666;
					}
				}
			}

			button {
				width: 154rpx;
				height: 60rpx;
				background: linear-gradient(270deg, #3078FF 0%, #009DFE 100%);
				border-radius: 46rpx;
				margin: 0px;
				display: flex;
				justify-content: center;
				align-items: center;
				color: #fff;
				font-size: 26rpx;
			}
		}

		.tips {
			width: auto;
			background: #FFFFFF;
			border-radius: 16rpx;
			display: flex;
			padding: 30rpx;
			margin-top: 20rpx;

			.title {
				font-family: PingFangSC, PingFang SC;
				font-weight: 500;
				font-size: 24rpx;
				color: #000000;
			}

			.viewFlex {
				width: auto;
				margin-left: 10rpx;

				view {
					display: flex;
					align-items: center;

					text {
						font-family: PingFangSC, PingFang SC;
						font-weight: 500;
						font-size: 24rpx;
						color: #666666;
					}
				}
			}
		}

		.working_hours {
			display: flex;
			align-items: center;

			.view {
				display: flex;
				align-items: center;
				margin-right: 50rpx;
				margin-top: 40rpx;

				/deep/ .u-image {
					margin-right: 10rpx;
				}
			}
		}

		.scrollBody {
			margin-top: 10rpx;

			text {
				font-family: PingFangSC, PingFang SC;
				font-weight: 500;
				font-size: 28rpx;
				color: #333333;
			}
		}


		.headers {
			width: auto;
			border-radius: 20rpx;
			padding: 20rpx 20rpx 30rpx 20rpx;
			background-color: #fff;
			display: flex;
			justify-content: space-between;
			align-items: center;
			margin-top: 30rpx;
			box-shadow: 0rpx 6rpx 24rpx 0rpx rgba(218, 218, 218, 0.5);

			.view {
				width: 100%;
				white-space: nowrap;

				.week {
					font-family: PingFangSC, PingFang SC;
					font-weight: 600;
					font-size: 24rpx;
					color: #333333;

				}

				.sun {
					font-family: PingFangSC, PingFang SC;
					font-weight: 600;
					font-size: 32rpx;
					color: #333333;
					margin-top: 10rpx;
				}

				view {
					width: 50rpx;
					display: inline-block;
					white-space: nowrap;
					display: flex;
					flex-wrap: wrap;
					justify-content: center;
					// border:1px solid red;
					padding-left: 10rpx;
					padding-right: 10rpx;

					text {
						display: inline-block;
						text-align: center;

					}
				}
			}
		}

		.NewFlex {
			justify-content: space-between;

			/deep/ .u-image {
				margin-left: 10rpx;
			}

			.time {
				font-family: PingFangSC, PingFang SC;
				font-weight: 400;
				font-size: 24rpx;
				color: #4C4C4C;
			}
		}

		.headers_title {
			width: auto;
			// margin: 0px auto;
			display: flex;
			align-items: center;
			margin-top: 60rpx;

			.view {
				width: 10rpx;
				height: 34rpx;
				background: #029CFE;
				border-radius: 6rpx;
			}

			.flex {
				display: flex;
				align-items: center;
			}

			text {
				font-family: PingFangSC, PingFang SC;
				font-weight: 600;
				font-size: 36rpx;
				color: #333333;
				margin-left: 10rpx;
			}
		}
	}
</style>